home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Unix / sys⁄dir.h < prev    next >
Encoding:
Text File  |  1989-11-06  |  2.2 KB  |  65 lines  |  [TEXT/????]

  1. /*    @(#)dir.h 2.10 88/02/08 SMI     */
  2.  
  3. /*
  4.  * Filesystem-independent directory information. 
  5.  * Directory entry structures are of variable length.
  6.  * Each directory entry is a struct direct containing its file number, the
  7.  * offset of the next entry (a cookie interpretable only the filesystem 
  8.  * type that generated it), the length of the entry, and the length of the 
  9.  * name contained in the entry.  These are followed by the name. The
  10.  * entire entry is padded with null bytes to a 4 byte boundary. All names 
  11.  * are guaranteed null terminated. The maximum length of a name in a 
  12.  * directory is MAXNAMLEN, plus a null byte.
  13.  * Note: this file is present only for backwards compatibility. It is superseded
  14.  * by the files /usr/include/dirent.h and /usr/include/sys/dirent.h. It will
  15.  * disappear in a future major release.
  16.  */
  17.  
  18. #define    MAXNAMLEN    255
  19.  
  20. struct    direct {
  21.     off_t   d_off;            /* offset of next disk directory entry */
  22.     u_long    d_fileno;        /* file number of entry */
  23.     u_short    d_reclen;        /* length of this record */
  24.     u_short    d_namlen;        /* length of string in d_name */
  25.     char    d_name[MAXNAMLEN + 1];    /* name (up to MAXNAMLEN + 1) */
  26. };
  27.  
  28. /* 
  29.  * The macro DIRSIZ(dp) gives the minimum amount of space required to represent
  30.  * a directory entry.  For any directory entry dp->d_reclen >= DIRSIZ(dp).
  31.  * Specific filesystem typesm may use this macro to construct the value
  32.  * for d_reclen.
  33.  */
  34. #undef DIRSIZ
  35. #define DIRSIZ(dp)  \
  36.     (((sizeof (struct direct) - (MAXNAMLEN+1) + ((dp)->d_namlen+1)) + 3) & ~3)
  37.  
  38. #ifndef KERNEL
  39. #define d_ino    d_fileno        /* compatability */
  40.  
  41.  
  42. /*
  43.  * Definitions for library routines operating on directories.
  44.  */
  45.  
  46. typedef struct _dirdesc {
  47.     int    dd_fd;            /* file descriptor */
  48.     long    dd_loc;             /* buf offset of entry from last readddir() */
  49.     long    dd_size;        /* amount of valid data in buffer */
  50.     long    dd_bsize;        /* amount of entries read at a time */
  51.     long    dd_off;                 /* Current offset in dir (for telldir) */
  52.     char    *dd_buf;        /* directory data buffer */
  53. } DIR;
  54.  
  55. #ifndef NULL
  56. #define NULL 0
  57. #endif
  58. extern    DIR *opendir();
  59. extern    struct direct *readdir();
  60. extern    long telldir();
  61. extern    void seekdir();
  62. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  63. extern    int closedir();
  64. #endif
  65.